
<script setup lang="ts">
import Btn2imgUpload from "@/components/common/btn2imgUpload.vue";
import EnterpriseElement from "@/components/common/enterpriseElement.vue";
import ElementContainer from "@/components/common/elementContainer.vue";
import {onMounted, ref} from "vue";
import {
  getRecommendEnterpriseApi,
  getRecommendFollowPostApi,
  getRecommendRecruitApi,
  getRecommendUserApi
} from "@/api/path/recommend";
import {ElMessage} from "element-plus";
import PostUnit from "@/components/post/PostUnit.vue";
import EnterpriseRecommend from "@/components/recommend/enterpriseRecommend.vue";
import PostRecommend from "@/components/recommend/postRecommend.vue";
import RecruitRecommend from "@/components/recommend/recruitRecommend.vue";
import UserRecommend from "@/components/recommend/userRecommend.vue";

const dataList = ref(
    [
      {
        enterpriseName: '1234',
        enterpriseIntro: '1223',
        enterpriseImgKey: '1223',
        enterpriseClass: '1223',
        enterpriseContactWay: '1223',
        followerNum: 0,
        admin_id: 0,
        admin_name: '1223',
      },
      {
        enterpriseName: '12341',
        enterpriseIntro: '12213',
        enterpriseImgKey: '12213',
        enterpriseClass: '12231',
        enterpriseContactWay: '1223',
        followerNum: 0,
        admin_id: 0,
        admin_name: '1223',
      },
      {
        enterpriseName: '12344231',
        enterpriseIntro: '122fwefw13',
        enterpriseImgKey: '12vr213',
        enterpriseClass: '12f231',
        enterpriseContactWay: '122rw4wf3',
        followerNum: 0,
        admin_id: 0,
        admin_name: '1rwrw4rw2231111111111111111111111111111111111111111111',
      }
    ]
);
const dataList1 = ref(
    [
      {
        id: 1,
        name: "58Q83",
        sex: 'M',
        education: "本科",
        school: "北京航空航天大学",
        skills: "人工智能、大数据分析",
        intro: "主要从事软件工程、信号与信息处理、大数据分析、人机交互、科技金融、人工智能等方面的研究。",
        in_enterprise: true,
        enterprise_id: 1,
        enterprise_name: "神奇技术公司",
        enterprise_position: "总经理",
        is_admin: true,
      },
      {
        id: 1,
        name: "58Q83",
        sex: 'M',
        education: "本科",
        school: "北京航空航天大学",
        skills: "人工智能、大数据分析",
        intro: "主要从事软件工程、信号与信息处理、大数据分析、人机交互、科技金融、人工智能等方面的研究。",
        in_enterprise: true,
        enterprise_id: 1,
        enterprise_name: "神奇技术公司",
        enterprise_position: "总经理",
        is_admin: true,
      },
      {
        id: 1,
        name: "58Q83",
        sex: 'M',
        education: "本科",
        school: "北京航空航天大学",
        skills: "人工智能、大数据分析",
        intro: "主要从事软件工程、信号与信息处理、大数据分析、人机交互、科技金融、人工智能等方面的研究。",
        in_enterprise: true,
        enterprise_id: 1,
        enterprise_name: "神奇技术公司",
        enterprise_position: "总经理",
        is_admin: true,
      }
    ]
);
const dataList2 = ref(
    [
      {
        id: 1,
        name: "超级工程师",
        salary: "18K-25K",
        education: "硕士",
        place: "北京海淀区学院路",
        enterprise_id: "1",
        enterprise_name: "神奇技术公司",
        enterprise_industry: "IT",
        enterprise_image_key: "https://p2.itc.cn/q_70/images03/20220826/4420c63c8fd849f1933cc21315a9b72b.jpeg",
        admin_id: 1,
        admin_name: "58Q83"
      },
      {
        id: 1,
        name: "超级工程师",
        salary: "18K-25K",
        education: "硕士",
        place: "北京海淀区学院路",
        enterprise_id: "1",
        enterprise_name: "神奇技术公司",
        enterprise_industry: "IT",
        enterprise_image_key: "https://p2.itc.cn/q_70/images03/20220826/4420c63c8fd849f1933cc21315a9b72b.jpeg",
        admin_id: 1,
        admin_name: "58Q83"
      },
      {
        id: 1,
        name: "超级工程师",
        salary: "18K-25K",
        education: "硕士",
        place: "北京海淀区学院路",
        enterprise_id: "1",
        enterprise_name: "神奇技术公司",
        enterprise_industry: "IT",
        enterprise_image_key: "https://p2.itc.cn/q_70/images03/20220826/4420c63c8fd849f1933cc21315a9b72b.jpeg",
        admin_id: 1,
        admin_name: "58Q83"
      }
    ]
);
const postList = ref([]);
const userList = ref([]);
const enterpriseList = ref([]);
const recruitList = ref([]);
onMounted(() => {
  getRecommendFollowPostApi().then((res: any) => {
    if (res.errno == 1) {
      postList.value.push(...res.userActivities);
      // console.log(postList.value)
    }
    else {
      // ElMessage.error(res.msg);
    }
  })
  getRecommendUserApi().then((res: any) => {
    if (res.errno == 1) {
      userList.value.push(...res.userIds);
    }
    else {
      // ElMessage.error(res.msg);
    }
  })
  getRecommendEnterpriseApi().then((res: any) => {
    if (res.errno == 1) {
      enterpriseList.value.push(...res.enterpriseIds);
    }
    else {
      // ElMessage.error(res.msg);
    }
  })
  getRecommendRecruitApi().then((res: any) => {
    if (res.errno == 1) {
      recruitList.value.push(...res.jobIds);
    }
    else {
      // ElMessage.error(res.msg);
    }
  })
})
</script>
<template>
<!--  <main style="width: 100vw;height: 100vh;margin-left: 0px;">-->
<!--	  <div class="" style="width: 180px; height: 30px;background-color: #ffffff; color: #ffffff; cursor: pointer;" @click="topage('/')">-->
<!--	      		  <RouterLink to="/addstaff">-->
<!--	      		  		 员工管理-->
<!--	      		  </RouterLink>-->
<!--	      </div>-->
<!--  </main>-->
<!--  <element-container v-for="(ele, index) in dataList" :key="'_' + index" type="enterprise" :data="ele"></element-container>-->
<!--  <element-container v-for="(ele, index) in dataList1" :key="'_' + index" type="user" :data="ele"></element-container>-->
<!--  <element-container v-for="(ele, index) in dataList2" :key="'_' + index" type="recruit" :data="ele"></element-container>-->
  <span class="content-wrapper">
    <span style="margin-right: 30px; width: 300px" class="content-container">
<!--      <recommend-recuitment v-for="(r, index) in recruitList" :key="'recruit'+index" :id="r"></recommend-recuitment>-->
      <recruit-recommend v-for="(r, index) in recruitList" :style="index%2!=0?'background-color: #fafafa':''" :key="'recruit'+index" :id="r"></recruit-recommend>
      <span style="display: flex; height: 100%; width: 100%; justify-content: center; align-items: center" v-if="recruitList.length == 0">
        暂无信息
      </span>
    </span>
    <span style="margin-right: 30px; width: 600px; background-color: transparent" class="content-container">
      <span style="display: flex; height: 100%; width: 100%; justify-content: center; align-items: center" v-if="postList.length == 0">
        暂无信息
      </span>
      <post-recommend v-else v-for="(p, index) in postList" :key="'post'+index" :id="p"></post-recommend>
    </span>
    <span style="width: calc(100% - 900px)" class="content-container">
<!--      <element-container v-for="(r, index) in userList" :key="'user'+index" :data="r" type="user"></element-container>-->
<!--      <element-container v-for="(r, index) in enterpriseList" :key="'enterprise'+index" :data="r" type="enterprise"></element-container>-->
      <user-recommend :style="index%2!=0?'background-color: #fafafa':''" v-for="(r, index) in enterpriseList" :key="'user'+index" :id="r"></user-recommend>
      <enterprise-recommend :style="(index + enterpriseList.length)%2!=0?'background-color: #fafafa':''" v-for="(r, index) in enterpriseList" :key="'enterprise'+index" :id="r"></enterprise-recommend>
<!--      {{userList.length}}{{enterpriseList.length}}{{userList.length + enterpriseList.length}}-->
      <span style="display: flex; height: 100%; width: 100%; justify-content: center; align-items: center" v-if="(userList.length + enterpriseList.length) == 0">
        暂无信息
      </span>
    </span>
  </span>
</template>

<style scoped>
*{
  padding: 0px;
  margin: 0px;
}
.content-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 100%;
  padding: 30px 100px;
  height: 100%;
  .content-container {
    height: 100%;
    overflow-y: auto;
    background-color: white;
    border-radius: 20px;
    /*background-color: red;*/
  }
}
</style>
